﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using System.Reflection;

namespace Microsoft.HomeServer.HomeServerConsoleTab.DuplicationInfo
{
    public partial class ErrorReportPanel : UserControl
    {
        public ErrorReportPanel(Exception ex)
        {
            InitializeComponent();

            iconPictureBox.Image = SystemIcons.Error.ToBitmap();

            string text = string.Empty;
            try
            {
                text += "== Duplication Info Error Report ==\r\n";
                text += string.Format("Version: {0}\r\n", Assembly.GetAssembly(this.GetType()).GetName().Version);
                text += string.Format("Date(UTC): {0}\r\n", DateTime.Now.ToUniversalTime());
                text += string.Format("Exception: {0}\r\n", ex.ToString());
            }
            finally
            {
                reportTextBox.Text = text;
            }
        }

        private void copyButton_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(reportTextBox.Text);
        }
    }
}
